//
//  myCoreTest.m
//  MyJPush
//
//  Created by 于洪东 on 16/6/1.
//  Copyright © 2016年 于洪东. All rights reserved.
//

#import "myCoreTest.h"

@interface myCoreTest ()

@property (nonatomic,strong) NSMutableArray *listenerM;

@end

@implementation myCoreTest
HMSingletonM(myCoreTest)


+(void)addListener:(id<myCoreProtocol>)listener{
    
    myCoreTest *test = [myCoreTest sharedmyCoreTest];
    
    if([test.listenerM containsObject:listener]) return;
    
    [test.listenerM addObject:listener];
    
}


-(void)didSomething:(NSDictionary *)userInfo{
    NSLog(@">>>>>>%@",userInfo);
    
    if(self.listenerM.count==0) return;
    
    [self.listenerM enumerateObjectsUsingBlock:^(id<myCoreProtocol> listener, NSUInteger idx, BOOL *stop) {
        
        if([listener respondsToSelector:@selector(didSomething:)]) [listener didSomething:userInfo];
    }];

}

#pragma mark - get 和 set 方法
-(NSMutableArray *)listenerM{
    
    if(_listenerM==nil){
        _listenerM = [NSMutableArray array];
    }
    
    return _listenerM;
}


@end
